package com.iwhalecloud.bss.kite.cucc.service.attr.handler;

import com.iwhalecloud.bss.kite.common.constant.ServiceOfferConsts;
import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.cucc.common.constant.LocalServiceOfferConsts;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import com.iwhalecloud.bss.kite.service.attr.handler.AbstractAttrHandler;
import com.ztesoft.bss.common.util.ContextUtil;

/**
 * @Classname OrgNameAttrHandler
 * @Description 产品属性初始赋值操作人的组织机构名称
 * @Author zhang.song
 * @Date 2021-02-23 09:31
 */
public class OrgNameAttrHandler extends AbstractAttrHandler<KiteInst, AttrData> {

    @Override
    public void after(KiteAttr attr, KiteInst inst, AttrData data) {
        super.after(attr, inst, data);

        // 订购、核查 操作
        if (KiteStringUtils.equalsAny(data.getServiceOfferId(), ServiceOfferConsts.SERVICE_OFFER_ORDER, LocalServiceOfferConsts.SERVICE_OFFER_RESOURCE_CHECK)) {
            if (KiteStringUtils.isEmpty(attr.getValue())) {
                String orgName = ContextUtil.getLoginInfo().getOrgInfo().getOrgName();
                attr.setValue(orgName);
            }
        }
    }
}
